#pragma once
#include <stdint.h>
#include "TerminalPosition.h"
#include "../Helpers/StringHelpers.h"

namespace IO{
    class Terminal{
    private:
        uint16_t* terminalBuffer = (uint16_t*)0xB8000;
        uint8_t _xpos=0;
        uint8_t _ypos=0;
        uint8_t _color=0x0F;
        void IntToString(int number, uint8_t base, char* output);
    public:
        Terminal();
        void ClearTerminal();
        void Put_Char(char c);
        void Put_String(const char* str);
        void SetPosition(TerminalPosition pos);
        void SetForegroundColor(uint8_t color);
        void SetBackgroundColor(uint8_t color);

        Terminal& operator<< (const char* const input){
            this->Put_String(input);
            return *this;
        }

        Terminal& operator<< (const int32_t input){
            char buffer[256];
            Helpers::StringHelpers::IntToString(input,10,buffer);
            this->Put_String(buffer);
            return *this;
        }

    };
}
